<?php
/*
Plugin Name: Communit.as Synchronization
Plugin URI: http://jaybill.com/wordpress-plugins/communit.as/
Description: This plugin syncronizes communit.as and wordpress.
Version: 1.0
Author: Jaybill McCarthy
Author URI: http://jaybill.com
*/

// This plugin needs to get put in the wordpress wp-content/plugins directory


function triggerUpdate($post_id){

	$ch = curl_init();

	// set URL and other appropriate options
	curl_setopt($ch, CURLOPT_URL, "http://name_of_your_site/cms/index/sync");
	curl_setopt($ch, CURLOPT_HEADER, 0);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

	// grab URL and pass it to the browser
	$throw_away = curl_exec($ch);

	// close cURL resource, and free up system resources
	curl_close($ch);

}

function triggerDelete($post_id){

	$ch = curl_init();

	// set URL and other appropriate options
	curl_setopt($ch, CURLOPT_URL, "http://name_of_your_site/cms/index/delete/id/".$post_id);
	curl_setopt($ch, CURLOPT_HEADER, 0);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

	// grab URL and pass it to the browser
	$throw_away = curl_exec($ch);

	// close cURL resource, and free up system resources
	curl_close($ch);

}



add_action('save_post', 'triggerUpdate');
add_action('delete_post', 'triggerDelete');